package com.cn.goodsadmin.requestinfo;

import com.alibaba.fastjson.JSONObject;
import com.cn.goodsadmin.common.frame.BaseHttpNetWork;
import com.cn.goodsadmin.common.frame.RequestInfo;

public class WxSendMsgRequest extends BaseHttpNetWork {
    public WxSendMsgRequest(RequestInfo info) {
        super(info);
        method="POST";
    }

    @Override
    public void setHeader() {

    }

    @Override
    public byte[] setBody(RequestInfo info) {
       WxSendMsgRequestInfo wxSendMsgRequestInfo=(WxSendMsgRequestInfo)info;
       try{
           JSONObject object=new JSONObject();
           object.put("touser",wxSendMsgRequestInfo.touser);
           object.put("msgtype",wxSendMsgRequestInfo.msgType);
           JSONObject contentJson=new JSONObject();
           contentJson.put("content",wxSendMsgRequestInfo.message);
           object.put("text",contentJson);
           String content=object.toJSONString();
           return content.getBytes("utf-8");
       }catch (Exception e){
            return null;
       }

    }

    @Override
    public void modifyUrl(RequestInfo info) {

    }
}
